package com.wsl.tibet_sprcifcation.contorller;

import com.dym.util.Result;
import com.wsl.pojo.Tb_specification;
import com.wsl.pojo.Tb_specificationS;
import com.wsl.service.Tb_specificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/specifcation")
public class Tb_specificationContorller {
    @Autowired
    private Tb_specificationService tb_specificationService;
    @RequestMapping("/insert")
    public Result insert1(@RequestBody Tb_specification tb_specification){
        try{
            tb_specificationService.insert1(tb_specification);
            return new Result(true,"添加成功");
        }catch (Exception ex){
            ex.printStackTrace();
            return new Result(false,"添加失败");
        }
    }
    @RequestMapping("/selectById/{id}")
    public Tb_specification selectById(@PathVariable("id") Long id){
        return tb_specificationService.selectById(id);
    }
    @RequestMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable("id") Long id){
        try{
            tb_specificationService.deleteById(id);
            return new Result(true,"删除成功");
        }catch (Exception ex){
            ex.printStackTrace();
            return new Result(false,"删除失败");
        }
    }
    @RequestMapping("/update")
    public Result update(@RequestBody Tb_specification tb_specification){
        try {
            tb_specificationService.update(tb_specification);
            return new Result(true,"修改成功");
        }catch (Exception ex){
            ex.printStackTrace();
            return new Result(false,"修改失败");
        }
    }
}
